package mygameserver;

/**
 * Created by IntelliJ IDEA.
 * User: Awake
 * Date: 06.03.12
 * Time: 11:51
 * To change this template use File | Settings | File Templates.
 */
enum CommandsList {
    CONNECT(".conn"), UPDATE(".update"), SET_CELL(".set"), GAME_REQUEST(".request"),
    GAME_RESUME(".resume"), HASH_CODE(".hash"), CLOSE_CONNECTION(".bye"),
    APPROVE(".approve"), START_GAME(".start"), ADD_PLAYER(".add"), REMOVE_PLAYER(".remove");

    private CommandsList(String abbr) {
        this.abbr = abbr;
    }

    public String getAbbr() {
        return abbr;
    }

    static public CommandsList getCommand(String str) {
        for (CommandsList sc : CommandsList.values()) {
            if (sc.getAbbr().equals(str)) {
                return sc;
            }
        }
        throw new RuntimeException("unknown type");
    }

    private String abbr;
}